from app import db,models
from datetime import datetime, timedelta


# user4 = models.User.query.get(7)
# print user4.id
# p = models.Post(body='this is my first blog',timestamp=datetime.datetime.utcnow(),user_id=user4.id)
# db.session.add(p)
# db.session.commit()
#
#
# users = models.User.query.all()
# print users
#
# for u in users:
#     print u.id,u.nickname

#
# users = models.User.query.all()
# for u in users:
#     db.session.delete(u)
#
# post = models.Post.query.all()
# for p in post:
#     db.session.delete(p)
#
# db.session.commit()

# make four users
from app.models import User, Post

u1 = User.query.filter_by(nickname='john').first()

u2 = User.query.filter_by(nickname='susan').first()

u3 = User.query.filter_by(nickname='mary').first()

u4 = User.query.filter_by(nickname='david').first()

# make four posts


# setup the followers
u1.follow(u1)  # john follows himself
u1.follow(u2)  # john follows susan
u1.follow(u4)  # john follows david
u2.follow(u2)  # susan follows herself
u2.follow(u3)  # susan follows mary
u3.follow(u3)  # mary follows herself
u3.follow(u4)  # mary follows david
u4.follow(u4)  # david follows himself
db.session.add(u1)
db.session.add(u2)
db.session.add(u3)
db.session.add(u4)
db.session.commit()
